from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework.viewsets import ModelViewSet

from apps.meiduo_admin.serializers.permission import PermissionSerializer, ContentTypeSerializer
from apps.meiduo_admin.utils import PageNum


class PermissionModelView(ModelViewSet):
    queryset = Permission.objects.all()
    serializer_class = PermissionSerializer
    pagination_class = PageNum

class ContentTypeAPIView(APIView):
    def get(self, request):
        content = ContentType.objects.all()
        serializer = ContentTypeSerializer(content, many=True)
        return Response(serializer.data)